package com.kitty.record.kittyio.netty.client;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

import java.time.LocalDateTime;
import java.util.UUID;

/**
 * @Description
 * @Author SHEN
 * @Date 2021/2/7
 */
public class MyClientHandler extends SimpleChannelInboundHandler<String> {


    @Override
    protected void channelRead0(ChannelHandlerContext ctx, String s) throws Exception {

        System.out.println(ctx.channel().remoteAddress()+":"+s);
        ctx.writeAndFlush("来自客户端对你全家的亲切问候" + LocalDateTime.now());
    }


    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        String msg = "来自客户端的问候！！！";
        ctx.writeAndFlush(msg);
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        cause.printStackTrace();
        ctx.close();
    }



}
